<template>
  <div class="main">
    <!-- 区域选择 -->
    <div class="city">
      <span class="iconfont icon-location location"></span>
      <span class="area">{{info.city}}</span>
      <span class="toggole" @click="isShow = !isShow">切换</span>
      <!-- 时间更新 -->
      <span class="updata-time"><i>{{info.reporttime}}</i>更新</span>
    </div>
    <div class="select" v-show="isShow">
      <ul>
        <li v-for="area in areasList" :key="area.id" @click="chooseArea(area.id)">{{area.name}}</li>
      </ul>
    </div>
    <div class="information">
      <div class="col1">
        <span class="celsius">{{info.temperature}}</span>
        <span class="celsius-font iconfont icon-yidongduan-"></span>
      </div>
      <div class="col2 wind-info">
        <div class="wind-info">
          <span class="iconfont icon-fengxiang"></span>
          <span class="wind-direction">{{info.winddirection}}风</span>
          <span class="wind-range">{{info.windpower}}级</span>
        </div>
        <div class="wet-info">
          <span class="iconfont icon-shidu"></span>
          <span class="wind-title">相对湿度</span>
          <span class="wind-num">{{info.humidity}}%</span>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  props: ['info'],
  name: 'Content',
  data() {
    return {
      areasList: [
        {name: '罗湖区', id: 440303},
        {name: '福田区', id: 440304},
        {name: '南山区', id: 440305},
        {name: '宝安区', id: 440306},
        {name: '龙岗区', id: 440307},
        {name: '盐田区', id: 440308},
        {name: '龙华区', id: 440309},
        {name: '坪山区', id: 440310},
        {name: '光明区', id: 440311},
      ],
      //是否显示选择框
      isShow: false
    };
  },
  methods: {
    //选择区域
    chooseArea(cityId) {
      this.isShow = false
      this.$emit('changeArea', cityId)
    }
  }
};
</script>
<style scoped>
  .main {
    padding-left: 40px;
    border: 1px solid #6590f6;
    border-top: none;
    height: 180px;
    position: relative;
    box-sizing: border-box;
  }
  .city {
    line-height: 60px;
    height: 60px;
  }
  .city span {
    font-size: 18px;
  }
  .city .area {
    font-size: 16px;
    font-weight: 500;
    color: #212121;
    padding-left: 5px;
    padding-right: 8px;
  }
  .city .toggole {
    border: 1px solid #6590f6;
    border-radius: 8px;
    font-size: 13px;
    text-align: center;
    color: #6590f6;
    font-weight: 600;
    padding: 0 5px;
    cursor: pointer;
  }
  .city .toggole:hover {
    color: #fff;
    background-color: #6590f6;
  }
  .city .updata-time {
    padding-left: 141px;
    color: #666;
    font-size: 16px;
  }
  .city .updata-time i {
    font-style: normal;
  }
  .information {
    position: relative;
    height: 100px;
    font-size: 14px;
  }
  .information > div {
    float: left;
  }
  .information .col1 {
    padding-left: 15px;
    padding-bottom: 15px;
  }
  .information .col1 .celsius{
    font-size: 80px;
    padding-right: 5px;
    color: #6590f6;
  }
  .information .col1 .celsius-font {
    position: absolute;
    top: 15px;
    color: #6590f6;
  }
  .information .wind-info {
    padding-bottom: 5px;
  }
  .information .col2 {
    margin-left: 100px;
    padding-top: 45px;
  }
  .information .col2 .wind-direction,
  .information .col2 .wind-title {
    padding: 0 8px;
  }
  /* 选择框 */
  .select {
    /* display: none; */
    position: absolute;
    top: 58px;
    left: 50%;
    transform: translateX(-50%);
    width: 400px;
    background-color: #fff;
    z-index: 999;
    border-top: 1px solid #6590f6;
  }
  .select ul li {
    float: left;
    list-style: none;
    width: calc(400px / 3);
    line-height: calc(120px / 3);
    text-align: center;
    box-sizing: border-box;
    color: #666;
  }
  .select ul li:hover {
    background-color: rgba(101, 144, 246, .09);
  }
</style>